package com.pyb.controller;

/**
 * @version 1.0
 * @Author 彭彦彬
 * @Date 2025/5/14 20:17
 * @注释
 */

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/fakeData")
public class FakeDataServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 创建伪造的数据
        List<String> dataList = new ArrayList<>();
        dataList.add("数据项 1");
        dataList.add("数据项 2");
        dataList.add("数据项 3");

        // 将数据放入请求属性中
        request.setAttribute("dataList", dataList);

        // 转发请求到JSP页面
        request.getRequestDispatcher("/WEB-INF/jsp/displayData.jsp").forward(request, response);
    }
}